/*
 * @Description: 全局过滤器
 * @Author: 0001100986/LiuShuai
 * @Date: 2021-09-22 14:00:25
 * @LastEditTime: 2021-09-22 14:22:44
 * @LastEditors: 0001100986/LiuShuai
 */

// 软件SN过滤
const filterSN = (val) => {
  if (val === '' || val === null || val === undefined) {
    return '';
  } else {
    // 转换数组
    let mac = val.split(':');
    for (let i = 0; i < mac.length; i++) {
      if (i === 0) {
        if (mac[i].length === 2) {
          mac[i] = mac[i];
        } else {
          mac[i] = '0' + mac[i];
        }
      } else {
        if (mac[i].indexOf(' ') === 0) {
          mac[i] = '0' + mac[i].substring(1, mac[i].length);
        }
      }
    }
    mac = mac.join(':');
    return mac;
  }
};

export default { filterSN };